package com.hyjy.music.util

import android.content.Context
import android.content.SharedPreferences
import com.hyjy.music.ContextHolder

const val KEY_PLAY_MODE = "play_mode"
const val KEY_LRC_COLOR = "lrc_color"
const val KEY_LRC_SIZE = "lrc_size"
const val KEY_SWITCH_STATUS = "switch_status"
const val KEY_SWITCH_STATUS_ROLL = "switch_status_roll"

val sp: SharedPreferences by lazy {
    ContextHolder.context.getSharedPreferences("config", Context.MODE_PRIVATE)
}

fun getBoolean(key: String, defValue: Boolean): Boolean {
    return sp.getBoolean(key, defValue)
}

fun getString(key: String, defValue: String?): String? {
    return sp.getString(key, defValue)
}

fun getInt(key: String, defValue: Int): Int {
    return sp.getInt(key, defValue)
}


fun putBoolean(key: String, value: Boolean) {
    sp.edit().putBoolean(key, value).apply()
}

fun putString(key: String, value: String?) {
    sp.edit().putString(key, value).apply()
}

fun putInt(key: String, value: Int) {
    sp.edit().putInt(key, value).apply()
}